package com.leyou.mq;

import com.leyou.client.GoodsClient;
import com.leyou.mapper.LogMapper;
import com.leyou.pojo.Log;
import com.leyou.pojo.Spu;
import com.leyou.service.PageService;
import com.leyou.service.TestService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class ItemListener {

    @Autowired
    private PageService pageService;

    @Autowired
    private TestService testService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "page.create.index.queue", durable = "true"),
            exchange = @Exchange(
                    value = "leyou.item.exchange",
                    ignoreDeclarationExceptions = "true",
                    type = ExchangeTypes.TOPIC),
            key = {"item.insert", "item.update"}))
    public void listenCreate(Long spuId){
        try{
            testService.test();
        }catch (Exception e){
            System.out.println(e.getMessage());
        }

       //pageService.createHtml(spuId);
    }
}
